package com.iot.core.data.mapper;


import com.iot.core.data.IdNameDto;
import com.iot.core.data.entity.HtTbid;
import com.iot.core.manager.id.HtIdManager;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface HtDbMapper extends MyBaseMapper<HtTbid> {
    @Select( value = {" <script> " +
            "select a.Name \n" +
            "from ${tbName}  a\n" +
            "where a.id=#{Id} \n" +
            " </script>"})
    String getName(String tbName,Long Id  );

    @Select( value = {" <script> " +
            "select a.Id,a.Name \n" +
            "from ${tbName}  a\n" +
            "where a.id in \n" +
            "<foreach item=\"item\" index=\"index\" collection=\"lst\" open=\"(\" separator=\",\" close=\")\">  \n" +
            "     #{item}\n" +
            "    </foreach>  "+

            " </script>"})
    List<IdNameDto> getNames(String tbName, List<Long> lst);

    default Long nextLong(){
        return HtIdManager.getInstance().nextLong();
    }
}
